package com.sugon.stream;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.function.Consumer;


public class FunctionInterface {

    public static void main(String[] args) {
        List<String> list = Arrays.asList("a", "bb", "ccc");
        int[] num = new int[]{1, 2};
        List<int[]> nums = Arrays.asList(new int[]{1, 3});

        /**
         * 遍历list集合，数据消费器
         */
       list.forEach(new Consumer<String>() {
           @Override
           public void accept(String s) {
               System.out.println(s);
           }
       });



       list.forEach((s)-> System.out.println(s));

       list.forEach(System.out::println);

       list.sort(new Comparator<String>() {
           @Override
           public int compare(String o1, String o2) {
               return o1.length()-o2.length();
           }
       });

       list.sort((s1, s2) -> s1.length() - s2.length());

    }
}
